// pages/mine/mine.js
var api = require('../../utils/api.js');
Page({
    /**
     * 页面的初始数据
     */
    data: {
      apipath: api.Apipath,
      denglu: false
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      var that = this;
      if (wx.getStorageSync('userid')) {
        var role = wx.getStorageSync('role');
        if(role == 2){
          wx.navigateTo({
            url: '/pages/my/my'
          })
        }
        wx.request({
          url: api.UserInfo,
          data: { userid: wx.getStorageSync('userid'),role: role },
          method: 'GET',
          success: function (res) {
            that.setData({ userInfo: res.data.data,denglu: true })
          },
        })
      } else {
        wx.navigateTo({
          url: '/pages/signin/signin',
        })
      }
    },
    hz_information:function(e){
      var $this = this;
      var id = e.currentTarget.dataset.id;
        wx.navigateTo({
          url: '/pages/hz_information/hz_infornation?id=' + id,
        })
    },
    logout: function () {
      wx.showModal({
        title: '',
        content: '是否退出登录?',
        showCancel: true,//是否显示取消按钮
        cancelText: "取消",//默认是“取消”
        cancelColor: '#999999',//取消文字的颜色
        confirmText: "确定",//默认是“确定”
        confirmColor: '#999999',//确定文字的颜色
        mask: true,
        success: function (res) {
          if (res.cancel) {
            //点击取消,默认隐藏弹框
          } else {
            //点击确定
            wx.clearStorage();
            wx.reLaunch({
              url: '/pages/signin/signin',
            })
          }
        },
      })
    },
    

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {


  },
  heathone: function () {
    wx.navigateTo({
      url: '/pages/appointment/appointment',
    })
  },
  heathtwo: function () {
    wx.navigateTo({
      url: '/pages/consult/consult',
    })
  },

  heath1: function () {
    wx.navigateTo({
      url: '/pages/hz_information/hz_infornation',
    })
  },
  heath2: function () {
    wx.navigateTo({
      url: '/pages/hz_zixunjilu/hz_zixunjilu',
    })
  },
  heath3: function () {
    wx.navigateTo({
      url: '/pages/subscribe/subscribe',
    })
  },
  heath4: function () {
    wx.navigateTo({
      url: '/pages/members/members',
    })
  },
  heath5: function () {
    wx.navigateTo({
      url: '/pages/edit_hzda/edit_hzda',
    })
  },
  heath6: function () {
    wx.navigateTo({
      url: '/pages/services/services',
    })
  },
  logout: function () {
    wx.showModal({
      title: '',
      content: '是否退出登录?',
      showCancel: true, //是否显示取消按钮
      cancelText: "取消", //默认是“取消”
      cancelColor: '#999999', //取消文字的颜色
      confirmText: "确定", //默认是“确定”
      confirmColor: '#999999', //确定文字的颜色
      mask: true,
      success: function (res) {
        if (res.cancel) {
          //点击取消,默认隐藏弹框
        } else {
          //点击确定
          wx.clearStorage();
          wx.reLaunch({
            url: '/pages/signin/signin',
          })
        }
      },
    })
  },
})